//
//  SendTalkBrowseCell.m
//  DongDongCircle
//
//  Created by 谢曦 on 2016/12/20.
//  Copyright © 2016年 gl. All rights reserved.
//

#import "PhotoBrowseViewCell.h"
@interface PhotoBrowseViewCell ()
@property (nonatomic,weak) UIImageView *pic;
@property (nonatomic,weak) UIButton *closeBtn;
@end
@implementation PhotoBrowseViewCell
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        [self configUI];
    }
    return self;
}
-(void)configUI{
   UIImageView  *pic=[[UIImageView alloc] init];
     [self.contentView addSubview:pic];
    pic.contentMode=UIViewContentModeScaleAspectFill;
    pic.layer.masksToBounds=YES;
    pic.userInteractionEnabled=YES;
    
    UIButton *close=[[UIButton alloc] init ];
    [close setImage:[UIImage imageNamed:@"icon_closepho"] forState:UIControlStateNormal];
    [self.contentView addSubview:close];
    [close addTarget:self action:@selector(delete:) forControlEvents:UIControlEventTouchUpInside];
    [pic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
           }];
    
    [close mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(-5);
        make.right.mas_equalTo(5);
        make.size.mas_equalTo(CGSizeMake(close.currentImage.size.width+5, close.currentImage.size.height+5) );
    }];
    
    _pic=pic;
    _closeBtn=close;
}
-(void)delete:(UIButton *)btn{
    if (self.DeleteButtonClickBlock) {
        _DeleteButtonClickBlock();
    }

}
-(void)setImage:(UIImage *)image
{
    _image=image;
    _pic.image=image;
}
-(void)setImageUrl:(NSString *)imageUrl{
    _imageUrl=imageUrl;
    [_pic sd_setImageWithURL:  kConfigImageUrl(imageUrl) completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        self.image=image;
        self.downImageBlock(image);
    }];
}
-(void)setIsHiddenDeleteButton:(BOOL)isHiddenDeleteButton{
    _isHiddenDeleteButton=isHiddenDeleteButton;
    _closeBtn.hidden=isHiddenDeleteButton;
}
@end
